let db=require('../../sql/common')

 exports.login=function(req,res){
    let params = req.body
    let sql='INSERT INTO user set ?'
    let sql2=`SELECT * FROM user WHERE userName='${params.userName}'`
    db.query(sql2,(err,ressql)=>{
        if(err){
            return res.send({status:204,err:err})
         }
         if(ressql.length){
            return res.send({status:200,res:'已存在',ressql:ressql})
         }
        db.query(sql,params,(err,ressql)=>{
                if(err){
                return res.send({status:204,err:err,msg:'登陆失败'})
                } 
                let _data={
                    res:'登陆成功',
                    ok:200
                }
                return res.send({status:200,_data:_data})


            })
    })
    
    
}

